package com.lc.dao.impl;

import com.lc.bean.Menu;
import com.lc.dao.DBUtils;
import com.lc.dao.MenuDao;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: ManolinCoder
 * @time: 2021/8/25
 */
public class MenuDaoImpl extends DBUtils implements MenuDao {
    //查询菜单列表
    @Override
    public List<Menu> getMenuList() {
        List<Menu> menuList = new ArrayList<>();
        String sql = "select * from menu";
        resultSet = query(sql,null);
        try {
            while (resultSet.next()){
                Menu menu = new Menu();
                menu.setMenuId(resultSet.getInt("menuid"));
                menu.setMenuName(resultSet.getString("menuname"));
                menu.setUpmenuId(resultSet.getInt("upmenuid"));
                menu.setState(resultSet.getInt("state"));
                menu.setDesc(resultSet.getString("desc"));
                menu.setUrl(resultSet.getString("url"));
                menuList.add(menu);
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            closeAll();
        }
        return menuList;
    }
}
